home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bailer.swf / scripts / frame_14 / DoAction.as
Text File  |  2013-04-24  |  4KB  |  167 lines

  1. chara_mc.state = 0;
  2. chara_mc.fno = 0;
  3. chara_mc.speed = chara_mc.ax = chara_mc.dir = 0;
  4. chara_mc.prevDown = false;
  5. chara_mc.ax = -20;
  6. chara_mc.gotoAndStop(4);
  7. suberu_sound.start(0);
  8. chara_mc.isBusy = function()
  9. {
  10.    return this.state != 0;
  11. };
  12. chara_mc.xSpin = function()
  13. {
  14.    this.state = 3;
  15.    this.gotoAndStop(11 + this.dir * 11);
  16. };
  17. chara_mc.onEnterFrame = function()
  18. {
  19.    var _loc2_ = this.dir;
  20.    var _loc3_ = this.ax;
  21.    if(gameState == 1 && isMouseDown && this.state != 2 || this._x < 0 || this._x > Stage.width)
  22.    {
  23.       if(csr_mc._currentframe == 1)
  24.       {
  25.          this.speed = -2;
  26.          this.dir = 0;
  27.       }
  28.       else
  29.       {
  30.          this.speed = 2;
  31.          this.dir = 1;
  32.       }
  33.    }
  34.    else if(gameState == 3 && this.state == 0 && (this._x < 290 || this._x > Stage.width - 290))
  35.    {
  36.       isMouseDown = true;
  37.       if(this._x < 290)
  38.       {
  39.          this.speed = 2;
  40.          this.dir = 1;
  41.       }
  42.       else
  43.       {
  44.          this.speed = -2;
  45.          this.dir = 0;
  46.       }
  47.    }
  48.    else
  49.    {
  50.       this.speed = 0;
  51.    }
  52.    if(this.speed == 0)
  53.    {
  54.       this.ax *= 0.9;
  55.    }
  56.    else
  57.    {
  58.       this.ax += this.speed;
  59.    }
  60.    this.ax = Math.max(Math.min(this.ax,MAX_SPEED),- MAX_SPEED);
  61.    this._x += this.ax;
  62.    var _loc4_ = (this._x - Stage.width / 2) * 100 / (Stage.width / 2);
  63.    suberu_sound.setPan(_loc4_);
  64.    if(this.state == 0 && (gameState == 1 || gameState == 3))
  65.    {
  66.       if(!this.prevDown && isMouseDown || (this.ax < 0 && _loc3_ >= 0 || this.ax >= 0 && _loc3_ < 0))
  67.       {
  68.          suberu_sound.stop();
  69.          suberu_sound.start(0);
  70.          this.gotoAndStop(2 + this.dir * 11);
  71.       }
  72.       else if(_loc2_ != this.dir)
  73.       {
  74.          this.gotoAndStop(4 + this.dir * 11);
  75.       }
  76.       if(!isMouseDown && Math.abs(this.ax) <= 1)
  77.       {
  78.          this.gotoAndStop(1 + this.dir * 11);
  79.       }
  80.    }
  81.    else if(this.state < 3)
  82.    {
  83.       if(_loc2_ != this.dir)
  84.       {
  85.          this.gotoAndStop(4 + getNo + this.dir * 11);
  86.       }
  87.    }
  88.    if(gameState == 3 && this.state == 0 && Math.abs(this.ax) < 1 && this.speed == 0)
  89.    {
  90.       this.xRemoveActionEvents();
  91.       this.gotoAndStop("doki");
  92.    }
  93.    this.prevDown = isMouseDown;
  94. };
  95. chara_mc.xActionEnd = function(fno)
  96. {
  97.    if(this.state == 1 || this.state == 2)
  98.    {
  99.       this.prevDown = false;
  100.       this.state = 0;
  101.       this.gotoAndStop(this._currentframe + fno);
  102.    }
  103. };
  104. chara_mc.xIsHit = function(mc)
  105. {
  106.    if(this.state != 0 || gameState != 1)
  107.    {
  108.       return false;
  109.    }
  110.    if(mc.no != 5)
  111.    {
  112.       var _loc3_ = [-10,10];
  113.       ox = 0;
  114.       oy = -20;
  115.    }
  116.    else
  117.    {
  118.       ox = 0;
  119.       oy = -40;
  120.    }
  121.    if(Math.abs(this._x + ox - mc._x) < 40 && Math.abs(this._y + oy - mc._y) < 40)
  122.    {
  123.       getNo = mc.no;
  124.       this.fno = 0;
  125.       this.state = getNo == 6 ? 2 : 1;
  126.       this.gotoAndStop(4 + getNo + this.dir * 11);
  127.       if(getNo != 6)
  128.       {
  129.          score += ITEM_SCORE[getNo - 1];
  130.       }
  131.       return true;
  132.    }
  133. };
  134. chara_mc.xRemoveActionEvents = function()
  135. {
  136.    delete this.onEnterFrame;
  137. };
  138. csr_mc.onMouseDown = function()
  139. {
  140.    isMouseDown = true;
  141. };
  142. csr_mc.onMouseUp = function()
  143. {
  144.    isMouseDown = false;
  145. };
  146. csr_mc.onEnterFrame = function()
  147. {
  148.    this.gotoAndStop(this._x <= chara_mc._x ? 1 : 2);
  149. };
  150. csr_mc.onMouseMove = function()
  151. {
  152.    this._x = _root._xmouse;
  153.    this._y = _root._ymouse;
  154.    this.gotoAndStop(this._x <= chara_mc._x ? 1 : 2);
  155.    updateAfterEvent();
  156. };
  157. csr_mc.xRemoveActionEvents = function()
  158. {
  159.    isMouseDown = false;
  160.    delete this.onEnterFrame;
  161.    delete this.onMouseMove;
  162.    delete this.onMouseDown;
  163.    delete this.onMouseUp;
  164. };
  165. Mouse.hide();
  166. csr_mc.onMouseMove();
  167.